package com.teamone.etl.taskmanager.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

/**
 任务数据输入表(EtlTaskInputInfo)表实体类

 @author makejava
 @since 2021-01-09 08:46:26 */
@SuppressWarnings("serial")
public class EtlTaskInputInfo extends Model<EtlTaskInputInfo> {
    /**
     id
     */
    @TableId(type = IdType.INPUT)
    private String id;
    /**
     节点ID
     */
    @TableField("node_id")
    private String nodeId;
    /**
     任务ID
     */
    @TableField("task_id")
    private String taskId;
    /**
     库名称
     */
    @TableField("database_name")
    private String databaseName;
    /**
     表名称
     */
    @TableField("table_name")
    private String tableName;
    /**
     表别名
     */
    @TableField("table_as_name")
    private String tableAsName;
    /**
     表字段
     */
    @TableField("table_field")
    private String tableField;
    /**
     表字段别名
     */
    @TableField("table_as_field")
    private String tableAsField;
    /**
     乐观锁
     */
    @TableField("revision")
    private Integer revision;
    /**
     创建人
     */
    @TableField("create_by")
    private String createBy;
    /**
     创建时间
     */
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;
    /**
     更新人
     */
    @TableField("update_by")
    private String updateBy;
    /**
     更新时间
     */
    @TableField("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    public EtlTaskInputInfo(JSONObject node,Date now) {
        this.nodeId=node.getString("id");
        JSONObject nodeData = node.getJSONObject("data");
        this.id= UUID.randomUUID().toString();
        this.taskId=nodeData.getString("taskId");
        this.databaseName=nodeData.getString("databaseName");
        this.tableName=nodeData.getString("tableName");
        this.tableAsName=nodeData.getString("tableAsName");
        this.tableField=nodeData.getString("tableField");
        this.tableAsField=nodeData.getString("tableAsField");
        this.createTime=this.updateTime=now;
    }


    public String getId () {
        return id;
    }

    public void setId (String id) {
        this.id = id;
    }

    public String getNodeId () {
        return nodeId;
    }

    public void setNodeId (String nodeId) {
        this.nodeId = nodeId;
    }

    public String getTaskId () {
        return taskId;
    }

    public void setTaskId (String taskId) {
        this.taskId = taskId;
    }

    public String getDatabaseName () {
        return databaseName;
    }

    public void setDatabaseName (String databaseName) {
        this.databaseName = databaseName;
    }

    public String getTableName () {
        return tableName;
    }

    public void setTableName (String tableName) {
        this.tableName = tableName;
    }

    public String getTableAsName () {
        return tableAsName;
    }

    public void setTableAsName (String tableAsName) {
        this.tableAsName = tableAsName;
    }

    public String getTableField () {
        return tableField;
    }

    public void setTableField (String tableField) {
        this.tableField = tableField;
    }

    public String getTableAsField () {
        return tableAsField;
    }

    public void setTableAsField (String tableAsField) {
        this.tableAsField = tableAsField;
    }

    public Integer getRevision () {
        return revision;
    }

    public void setRevision (Integer revision) {
        this.revision = revision;
    }

    public String getCreateBy () {
        return createBy;
    }

    public void setCreateBy (String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateTime () {
        return createTime;
    }

    public void setCreateTime (Date createTime) {
        this.createTime = createTime;
    }

    public String getUpdateBy () {
        return updateBy;
    }

    public void setUpdateBy (String updateBy) {
        this.updateBy = updateBy;
    }

    public Date getUpdateTime () {
        return updateTime;
    }

    public void setUpdateTime (Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     获取主键值

     @return 主键值
     */
    @Override
    protected Serializable pkVal () {
        return this.id;
    }
}